﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class admin_pdfgl_scslt : System.Web.UI.Page
{
    string message = string.Empty;
    string message2 = string.Empty;
    ImagePdf ip = new ImagePdf();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["admin_id"] == null)
        {
            Response.Redirect("admin_logout.aspx");
            return;
        }
        if (!IsPostBack)
        {
        }
        mode();
    }
    protected void bt_kj_Click(object sender, EventArgs e)
    {
        createImage("课件");
        wait_end();
        alert(message);
    }
    protected void bt_xt_Click(object sender, EventArgs e)
    {        
        createImage("习题");
        wait_end();
        alert(message);
    }
    protected void bt_wx_Click(object sender, EventArgs e)
    {
        createImage("文献");
        wait_end();
        alert(message);
    }
    protected void bt_bz_Click(object sender, EventArgs e)
    {
        createImage("标准");
        wait_end();
        alert(message);
    }
    protected void bt_jywz_Click(object sender, EventArgs e)
    {
        createImage("教研文章");
        wait_end();
        alert(message);
    }
    private void createImage(string type)
    {
        message = type + "PDF文件生成缩略图提示：";
        message += ip.CreatePdfImage(type);
        message2 += type + ip.CreatePdfImage(type);  
    }
    private void alert(string ms)
    {
        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "更新提示", "<script language='javascript'>  warning('"+ms+"');</script>");
    }

    private void mode()
    {
        if (RadioButton_update.Checked)
        {
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "更新模式", "<script language='javascript'>mode(false);</script>");
        }
        else
        {
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "更新模式", "<script language='javascript'>mode(true);</script>");
        }
    }

    private void wait_end()
    {
        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "更新结束", "<script language='javascript'>wait_end();</script>");
    }
    protected void bt_qb_Click(object sender, EventArgs e)
    {
        //删除全部pdf缩略图
        ip.DeletetPdfImage();
        message2 = "";
        createImage("课件");
        createImage("习题");
        createImage("文献");
        createImage("标准");
        createImage("教研文章");
        wait_end();
        alert(message2);
    }
    
}
